package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.repository.entity.OtherFile;
import com.dragon.repository.entity.ProduceProducts;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.dragon.common.util.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class ProduceProductsVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "供应商产品报价id")
    private Integer quotesProductId;

    @ApiModelProperty(value = "生产id")
    private Integer produceId;

    @ApiModelProperty(value = "合同数量")
    private Integer num;

    @ApiModelProperty(value = "生产数量")
    private Integer produceNum;

    @ApiModelProperty(value = "发货数量")
    private Integer deliverNum;

    @ApiModelProperty(value = "剩余数量")
    private Integer inventoryNum;

    @ApiModelProperty(value = "退货数量")
    private Integer rejectedNum;

    @ApiModelProperty(value = "排产完成数量")
    private Integer scheduledNum;

    @ApiModelProperty(value = "更新时间")
    private Date updateTime;

    @ApiModelProperty(value = "生产状态：0未生产1生产中2生产完成")
    private Integer produceStatus;

    @ApiModelProperty(value = "排产状态：0 未排产 1正在排产 2排产完成")
    private Integer schedulingStatus;

    @ApiModelProperty(value = "附件")
    private List<OtherFile> otherFileList;

    @ApiModelProperty(value = "是否外发 0否 1是")
    private Integer isOut;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static ProduceProducts convert(ProduceProductsVO vo) {
        ProduceProducts entity = new ProduceProducts();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<ProduceProducts> convertList(List<ProduceProductsVO> list) {
        List<ProduceProducts> resultList = new ArrayList<>();
        for (ProduceProductsVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
